import requests from '../common/request'

export function getBaseInfo() {
  return requests.get('/memberApp/member/base_info')
}
export function getExtInfo() {
  return requests.get('/memberApp/member/ext_info')
}
export function updateMemberInfo(data) {
  return requests.put({
    url: '/memberApp/member/data',
    data: data
  })
}

export function getAccountRule() {
  return requests.get('/memberApp/memberAccount/accountRule')
}
export function getAccountRuleNotMember(data) {
  if (data.otherMoney >= 0) {
    return requests.get('/memberApp/memberAccount/accountRuleNotMember?categoryId=' + data.categoryId + '&otherMoney=' + data.otherMoney)
  } else {
    return requests.get('/memberApp/memberAccount/accountRuleNotMember?categoryId=' + data.categoryId + '&money=' + data.money)
  }
}

export function getAccountPayConfig() {
  return requests.get('/memberApp/memberAccount/pay_config')
}


export function getAccount() {
  return requests.get('/memberApp/memberAccount/info')
}

export function getAccountInfoExt() {
  return requests.get('/memberApp/member/account_info')
}

export function checkPwdInit() {
  return requests.get('/memberApp/memberAccount/initialCheck')
}

export function getCategoryAvailable() {
  return requests.get({
    url: '/memberApp/memberCategory/available',
  })
}

export function getDynamicQRCode() {
  return requests.get('/memberApp/member/dynamicQRCode')
}

export function updatePhone(data) {
  return requests.post({
    url: '/memberApp/member/updatePhone',
    params: data
  })
}

export function getMemberGiveConfig() {
  return requests.get('/memberApp/memberGive/config')
}

export function memberGiveAway(data) {
  return requests.post({
    url: '/memberApp/memberGive/giveaway',
    data: data
  })
}

export function queryMemberGiveStatus(data) {
  return requests.get({
    url: 'memberApp/memberGive/queryStatus',
    data: data
  })
}
export function receiveMemberGive(params) {
  return requests.post({
    url: '/memberApp/memberGive/receive',
    params: params

  })
}



export function getGiveRecordDetail(data) {
  return requests.get({
    url: '/memberApp/memberGive/giveRecordDetail',
    data: data
  })
}

export function getGiveRecords(data) {
  return requests.get({
    url: '/memberApp/memberGive/records',
    data: data
  })
}


export function getMemberMineInfo() {
  return requests.get('/memberApp/member/mine')
}


export function activateCard(data) {
  return requests.post({
    url: '/memberApp/wxCard/activate_card',
    data: data
  })
}

export function getCategoryDetail(data) {
  return requests.get({
    url: '/memberApp/memberCategory/memberCategoryDetail',
    data: data
  })
}

/**
 * @desc 微信卡包接口的，也有对手机号解密逻辑在里面
 * 主要逻辑根据用户手机号查询用户是否是老会员以及微信卡包会员卡状态
 */
export function checkMemberCartState(data) {
  return requests.get({
    url: '/memberApp/member/wxCardState',
    data: data
  })
}

export function getOpenCardInfo(data) {
  return requests.get({
    url: '/memberApp/memberCategory/openCardInfo',
    data: data
  })
}

export function checkWxCardState(data) {
  return requests.get({
    url: '/memberApp/member/checkWxCardState',
    data: data
  })
}

export function updateToNewCard(data) {
  return requests.post({
    url: '/memberApp/biz/open_card',
    data: data
  })
}

export function openMemberCard(data) {
  return requests.post({
    url: '/memberApp/biz/open_card_new',
    data: data
  })
}

export function getMemberDataFields(data) {
  return requests.get({
    url: '/memberApp/member/memberDataFields',
    data: data
  })
}

export function balancePay(data) {
  return requests.post({
    url: '/memberApp/biz/balancePay',
    data: data
  })
}

export function getPayInfo(data) {
  return requests.get({
    url: '/memberApp/biz/payInfo',
    data: data
  })
}


export function queryOrder(data) {
  return requests.get({
    url: '/memberApp/biz/queryOrder',
    data: data
  })
}

export function getActivatePluginParam(data) {
  return requests.post({
    url: '/memberApp/wxCard/get_activate_plugin_param',
    data: data
  })
}

// 余额使用记录
export function getBalanceRecordList(data) {
  return requests.get({
    url: '/memberApp/memberRecords/balance/list',
    data: data
  })
}

export function getBalanceRecordCount(data) {
  return requests.get({
    url: '/memberApp/memberRecords/balance/count',
    data: data
  })
}

// 绑定老会员
export function queryOfflineMember(data) {
  return requests.get({
    url: '/memberApp/member/queryOfflineMember',
    data: data
  })
}

export function bindMember(data) {
  return requests.post({
    url: '/memberApp/member/bind',
    params: data
  })
}

// 充值
export function getRechargeAwards(data) {
  return requests.get({
    url: '/memberApp/biz/rechargeUpgradeInfo',
    data: data
  })
}

export function recharge(data) {
  return requests.post({
    url: '/memberApp/biz/recharge?money=' + data.money + "&payChannel=" + data.payChannel + "&mercNo=" + data.mercNo,
    data: data
  })
}

// 修改密码
export function resetPassword(data) {
  return requests.post({
    url: '/memberApp/memberAccount/resetPassword?newPassword=' + data.newPassword + "&oldPassword=" + data.oldPassword
  })
}

export function changePassword(data) {
  return requests.post({
    url: '/memberApp/memberAccount/changePassword?newPassword=' + data.newPassword + "&oldPassword=" + data.oldPassword
  })
}

// 邀请注册
export function inviteMember(data) {
  return requests.post({
    url: '/memberApp/inviteMember/share',
    data: data
  })
}

export function getInviteAwards(data) {
  return requests.get({
    url: '/memberApp/inviteMember/inviteBonus',
    data: data
  })
}

export function getInviteCount(data) {
  return requests.get({
    url: '/memberApp/inviteMember/counts',
    data: data
  })
}

export function getInviteRecords(data) {
  return requests.get({
    url: '/memberApp/inviteMember/records',
    data: data
  })
}

export function getPromotionCode(data) {
  return requests.get({
    url: '/memberApp/inviteMember/promotionCode',
    data: data
  })
}
export function registerPromoter(data) {
  return requests.get({
    url: '/memberApp/inviteMember/registerPromoter',
    data: data
  })
}


export function getWxaQrCode(data) {
  return requests.get({
    url: '/memberApp/member/wxAppQrcode',
    data: data
  })
}

export function getHigherCard(data) {
  return requests.get({
    url: '/memberApp/memberCategory/higherCard',
    data: data
  })
}

export function getRenewInfo(data) {
  return requests.get({
    url: '/memberApp/biz/renewInfo',
    data: data
  })
}
export function renewMember(data) {
  return requests.post({
    url: '/memberApp/biz/renewMember',
    data: data
  })
}

export function checkMemberAfterPay(data) {
  return requests.get({
    url: '/memberApp/member/memberAfterPay',
    data: data
  })
}

export function activateMemberAfterPay(data) {
  return requests.post({
    url: '/memberApp/member/activateMemberAfterPay',
    params: data
  })
}

//获取优惠券详情（新）
export function getCouponDetailNew(data) {
  return requests.get({
    url: '/couponApp/coupon/detail',
    data: data
  })
}

//领取卡
export function getCard(data) {
  return requests.post({
    url: '/couponApp/card/receive',
    data: data
  })
}

//查询是否开通超级会员
export function checkSuperMemberStatus(data) {
  return requests.post({
    url: '/memberApp/superMember/checkSuperMemberStatus',
    data: data
  })
}
//获取超级会员合作商户的店铺信息
export function getShopAndDistance(data) {
  return requests.post({
    url: '/memberApp/superMember/getShopAndDistance',
    data: data
  })
}
//获取是否存在报名二维码和报名数据按钮权限
export function getSignBtnStatus(data) {
  return requests.get({
    url: '/memberApp/tweeter/getOpenTweeterBusinessConfig',
    data
  })
}

// 判断是否绑定开卡手机号
export function checkBindMobile({ data = {}, header = {} }) {
  return requests.post({
    url: '/business_admin/cashier/checkMemberBindInfo',
    data: data,
    header
  })
}
// 获取手机验证码
export function getSmsCode(phone) {
  return requests.post({
    url: '/memberApp/sms/generateOpenCardVerificationCode',
    data: {
      phone
    }
  })
}
// 更绑手机号码
export function checkSmsCode({ data = {}, header = {} }) {
  return requests.post({
    url: '/business_admin/cashier/doMemeberInfoByAuthGetPhone',
    data,
    header
  })
}

// 更绑手机号码
export function checkPhoneCode({ data = {}, header = {} }) {
  return requests.post({
    url: '/business_admin/cashier/checkPhoneVerificationCode',
    data,
    header
  })
}

// updateOriginMemberPhone更新手机号码
export function updateMemberPhone({ data = {}, header = {} }) {
  return requests.post({
    url: '/business_admin/cashier/updateOriginMemberPhone',
    data,
    header
  })
}
// 授权校验手机号码
export function authCheckMobile({ data = {}, header = {} }) {
  return requests.post({
    url: '/business_admin/cashier/choicePhoneIsBind',
    data,
    header
  })
}

// 获取开卡权益
export function getRights(data) {
  return requests.post({
    url: '/memberRights/anon/getRights',
    data
  })
}

// *******************云南卡卡需求****************
// 检测设备序列号是否被绑定
export function isBindByDeviceSn(params) {
  return requests.get({
    url: '/memberApp/device/isBindByDeviceSn',
    params: params
  })
}
// 绑定设备
export function memberBindDev(data) {
  return requests.post({
    url: '/memberApp/device/memberBindDev',
    data
  })
}
// 获取会员绑定设备信息
export function getMemberDeviceById(data) {
  return requests.post({
    url: '/memberApp/device/getMemberDeviceById',
    data
  })
}

export function getCooperationBusiness(data) {
  return requests.post({
    url: '/pubDomainApp/superMember/getCooperationBusiness',
    data
  })
}
